var gulp = require("gulp");
var gulp_clean_css = require("gulp-clean-css");//压缩css代码
var gulp_sass = require("gulp-sass");
var gulp_mini_js = require("gulp-uglify");//压缩js
var gulp_tinypng = require("gulp-tinypng");
var gulp_autoprefixer = require ("gulp-autoprefixer");//添加前缀
var browser_sync = require("browser-sync").create();//开启监听
var gulp_plumber = require("gulp-plumber");//防止错误跳出命令


//编译sass的任务
gulp.task("miniscss",function(){
	gulp.src("src/scss/**/*.scss")
		.pipe(gulp_plumber())
	    .pipe(gulp_sass())
	    .pipe(gulp_plumber())
	    .pipe(gulp.dest("src/css/"))
})
//创建实时监听
gulp.task("dev",function(){
	browser_sync.init({
		port:1234,
		server:{
			baseDir:"./src"	
		}
	})
	gulp.watch("src/scss/**/*.scss",["miniscss"]).on('change',browser_sync.reload)
	gulp.watch("src/js/**/*.js").on('change',browser_sync.reload)
	gulp.watch("src/**/*.html").on('change',browser_sync.reload)
})